package com.yanqu.data.analytics;

import com.yanqu.data.analytics.impl.EmptyProvider;
import com.yanqu.data.analytics.impl.KafkaProvider;
import com.yanqu.data.analytics.impl.ThinkingProvider;
import org.apache.logging.log4j.Logger;

public class ProviderFactory {

    public static Provider getProvider(String type, Logger logger, String serverUrl) throws Exception{
        try {
            if ("TDA".equals(type)) {
                ThinkingProvider thinkingProvider = new ThinkingProvider(logger, serverUrl);
                thinkingProvider.init();
                return thinkingProvider;
            }else if("KAFKA".equals(type)){
                KafkaProvider thinkingProvider = new KafkaProvider(logger, serverUrl);
                thinkingProvider.init();
                return thinkingProvider;
            }
            return new EmptyProvider(logger);
        }catch (Exception e){
            logger.error("init provider error", e);
        }
        return new EmptyProvider(logger);
    }
}
